package org.jeecg.modules.homeModule.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Results;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.homeModule.entity.EventEntity;
import org.jeecg.modules.homeModule.service.HomeExhibitionService;
import org.jeecg.modules.zonglzp.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/home")
public class HomeExhibitionController {


    @Autowired
    HomeExhibitionService service;

    /*
   查订单数量 售后数量  面料数量
     */
    @GetMapping("/getordernumber")
    public Result<?>  ordernumber(){


        HashMap<String,Object>  numberMap=new HashMap<>();
        //订单数量
        int ordernumber=service.getordernumber();
        //获取售后订单数量
        int afternumber=service.getafternumber();
        //获取面料数量
        int mianliaonumber=service.getmianliaonumber();
        numberMap.put("ordernumber",ordernumber);
        numberMap.put("afternumber",afternumber);
        numberMap.put("mianliaonumber",mianliaonumber);
        return Result.ok(numberMap);
    }



    /*
    查询处理事件 以list的形式返回
     */
    @GetMapping("/geteventrecrodtList")
    public Result<?> geturgentList(
            @RequestParam(name = "type", defaultValue = "0") int type,
            @RequestParam(name = "begin", defaultValue = "0") int begin
    ){
        List<EventEntity> pageList=service.geteventrecrodtList(type,begin);
        return Result.ok(pageList);
    }

    /*
    修改事件状态
     */
    @GetMapping("/updateEventstatus")
    public Result<?> updateEventstatus(
            @RequestParam(name = "id") String  id,
            @RequestParam(name = "status") int status
    ){
           try {
               int count=service.updateEventstatus(id,status);
               return Result.ok("修改成功");
           }catch (Exception e){
               e.printStackTrace();
               return Result.error("修改失败");
           }
    }
}
